#pragma once

#include <vector>
#include <termios.h>

namespace Evil {

enum class Baud
{
    Rate_57600    = B57600  ,
    Rate_115200   = B115200 ,
    Rate_230400   = B230400 ,
    Rate_460800   = B460800 ,
    Rate_500000   = B500000 ,
    Rate_576000   = B576000 ,
    Rate_921600   = B921600 ,
    Rate_1000000  = B1000000,
    Rate_1152000  = B1152000,
    Rate_1500000  = B1500000,
    Rate_2000000  = B2000000,
    Rate_2500000  = B2500000,
    Rate_3000000  = B3000000,
    Rate_3500000  = B3500000,
    Rate_4000000  = B4000000
};    
    
    
    
class ConnectionInfo
{
public:
    ConnectionInfo( std::string &device, Baud baudRate )
    : m_device( device )
    , m_baudRate( baudRate ) 
    {
        
    }
    
    inline const std::string & device() const { return m_device; }
    
    inline  Baud & baudRate() const { return m_baudRate; }
    
private:
    Baud m_baudRate;
    
    std::string m_device;
};

struct IDeviceIOHandler
{
    virtual bool write( const char *msg, int len )  = 0;
    
    virtual bool write( std::string &msg )          = 0;
    
    virtual std::string read()                      = 0;
    
    virtual bool open( ConnectionInfo &info )       = 0;
    
    virtual bool close()                            = 0;
    
    virtual bool isOpen() const                     = 0;
    
    virtual const std::string & id() const          = 0;
};

}